YAML_FILE = ./lzc-manifest.release.yml
.PHONY: build-debug
build-debug:
	lzc-cli project build -o debug.lpk

.PHONY: build-release
build-release:
	# python update_version.py $(YAML_FILE)
	lzc-cli project build -f lzc-build.release.yml -o release.lpk

.PHONY: debug
debug: build-debug
	lzc-cli app install debug.lpk
	rm debug.lpk

.PHONY: release
release: build-release
	lzc-cli appstore publish release.lpk
	rm release.lpk
	VERSION=$$(grep '^version:' $(YAML_FILE) | cut -d ' ' -f2) && \
	git add $(YAML_FILE) && \
	git commit -m "chore: bump lpk to $$VERSION" && \
	git push origin master --no-verify

fp-dev:
	bash -x build-fp-dev.sh

fp:
	bash -x build-fp.sh

fp-publish:
	bash -x fp-publish.sh	

.PHONY: cleanup
cleanup:
	rm *.lpk

changelog:
	git log --since="$(since)" --format="%s"
# npm install -g @lazycatcloud/lzc-cli # 安装依赖工具
# lzc-cli box create # 创建盒子
#
# 进入盒子的命令
.PHONY: inbox
inbox:
	lzc-cli project devshell -r

# 本命令目标只在盒子内运行(进入盒子后，同步目录执行)
# 可同时启动前后端服务，可实时查看前后台日志
.PHONY: dev
dev: p1=["sh", "-c", "cd backend && go run ."]
dev: p2=["sh", "-c", "cd ui && exec npm run dev"]
dev:
	@echo 'import subprocess; [p.wait() for p in subprocess.Popen(${p1}),subprocess.Popen(${p2})]' | python2
